Welcome to Client-Side JavaScript with HTML. After watching this video, you will be able to define a client-side script, give examples of when
client-side scripts can be used, explain how to use the noscript tag, describe Event Binding in scripts. A client-side script is a program that accompanies an HTML document or might be embedded
directly in the HTML document itself. The script program runs on the client
device when the document loads, or at some other time such as when a link
is activated or when a button is clicked. Although JavaScript is widely used
as a scripting language in HTML, other scripting languages can be used instead. Scripts offer authors a means to modify and
extend HTML documents in highly interactive ways. Scripts can run after an HTML document is loaded. Scripts can be used to validate forms
or to process input as it is typed. Scripts can be triggered by events that occur
on a web page, such as the clicking of a button. Scripts can be used to dynamically
create document elements on an HTML page. This slide shows two ways
in which the script tag is used to include scripts in an HTML document. Example 1 demonstrates how you can include
a script directly inside the HTML document. This method is good for short
scripts, but when a script is long, the method used in example 2 is preferred. Example 2 uses the SRC attribute to
point to an external script file. This method has several use cases, such
as importing JavaScript libraries for complex interactions or using the same
script across several HTML documents. Some users who visit your website
might disable JavaScript from running, or they might be using a browser
that does not support scripting. To allow for these situations, place the content for the alternative
path within the noscript tag. If the browser does not support scripting, the browser runs the section of code
that is within the noscript tag. Scripts can run on the detection of certain events that happen when the page is
running in a browser session. Calling a function when an event
occurs is called event binding. For example, the onload event can run a script
when the browser finishes loading a page. Or a function can be performed
when the onclick event occurs. This event occurs when the pointing
device is clicked over an element, such as a button, that declares
a handler for the event. The event handler is a function that declares
what to do when the button is clicked. Other useful events include on-mouse-over, which
occurs when the cursor is moved onto an element. Here the inline event handler named
showAnswers runs when the button is clicked. In this video, you learned a client-side script is a program
that accompanies an HTML document. It may even be embedded into the HTML itself. Scripts offer developers ways to extend HTML
documents to enhance the user experience, especially by incorporating
more interactive elements. You can use the script tag to include
a script within the HTML document, or to call a script from an external file. Use the noscript tag to provide an
alternative when scripting is disabled. Scripts can be bound to events
so that they run automatically. For example, the onload event can a script
when the browser finishes loading a page.